function ccR_DeathKnight_MindFreeze()
	local vUseMindFreeze = ccRS.DeathKnight_UseMindFreeze
	if ccrValidTarget()
	and vUseMindFreeze	
	and ccrPlayerHasSpell(MIND_FREEZE)
	and SpellCanAttack(MIND_FREEZE)
	and ccrTargetIsCastingOrChanneling()
	and ccrTargetIsInteruptable()
	and (ccrTargetHasLeftOnCast(1) or ccrTargetIsChanneling())
	and (Last_Spell_Interuption_Used == nil or (GetTime()-Last_Spell_Interuption_Used > 2))
	then
		Last_Spell_Interuption_Used = GetTime()
		ccrCastAttack(MIND_FREEZE)
		return
	end
	return
end

function ccR_DeathKnight_Strangulate()
	local vUseStrangulate = ccRS.DeathKnight_UseStrangulate
	if ccrValidTarget()
	and vUseStrangulate
	and ccrPlayerHasSpell(STRANGULATE)
	and ccrTargetIsCastingOrChanneling()
	and ccrSpellCanAttack(STRANGULATE)
	and (not SpellIsReady(MIND_FREEZE) or not ccrTargetIsWithinMeleeRange())
	and ccrTargetIsInteruptable()
	and (Last_Spell_Interuption_Used == nil or (GetTime()-Last_Spell_Interuption_Used > 2))
	then
		ccrCastAttack(STRANGULATE)
		Last_Spell_Interuption_Used = GetTime()
		return
	end
	return
end

function ccR_DeathKnight_ChainsOfIce()
	local vUseChainsOfIce = ccRS.DeathKnight_UseChainsOfIce
	if ccrValidTarget()
	and ccrPlayerHasSpell(CHAINS_OF_ICE)
	and vUseChainsOfIce
	and ccrSpellCanAttack(CHAINS_OF_ICE)
	and ccrTargetIsMoving()
	and not ccrTargetHasDebuff(CHAINS_OF_ICE)
	and not ccrTargetIsBoss()
	then
		ccrCastAttack(CHAINS_OF_ICE)
		return
	end
	return
end

function ccR_DeathKnight_Dark_Simulacrum()
	local vUseDarkSimulalcrum = ccRS.DeathKnight_UseDarkSimualcrum
	if ccrValidTarget()
	and ccrPlayerHasSpell(DARK_SIMULACRUM)
	and ccrSpellIsReady(DARK_SIMULACRUM)
	then
		powerType, powerTypeString = UnitPowerType("target")
		if SpellCanAttack(DARK_SIMULACRUM)
		and ccrTargetIsCastingAtMe()
		and powerTypeString == "MANA"
		then
			ccrCastAttack(DARK_SIMULACRUM)
			return
		end
		return
	end
	return
end

function ccR_DeathKnight_Empower_Rune_Weapon()
	local vUseEmpowerRuneWeapon = ccRS.DeathKnight_UseEmpowerRuneWeapon
	if vUseEmpowerRuneWeapon
	and ccrPlayerHasSpell(EMPOWER_RUNE_WEAPON)
	and ccrSpellIsReady(EMPOWER_RUNE_WEAPON)
	and ccrTargetIsWithinMeleeRange()
	then
		local vRuneOnCD = 0;
		for i=1,6 do 
			local start, duration, runeReady = GetRuneCooldown(i)
			if runeReady == false then
				vRuneOnCD = vRuneOnCD + 1
			end
		end
		if vRuneOnCD >= 6
		and ccrRunicPower() <= 40
		then
			ccrCast(EMPOWER_RUNE_WEAPON);
			return
		end
		return
	end;
	return
end

function ccR_DeathKnight_Horn_of_Winter()
	local vUseHornOfWinter = ccRS.DeathKnight_UseHornOfWinter
	local vRunePower = ccRS.DeathKnight_HornOfWinterLimit
	if (not ccrPlayerHasBuff("Horn of Winter") or not ccrPlayerHasBuff("Trueshot Aura") or not ccrPlayerHasBuff("Battle Shout"))	
	and SpellIsReady("Horn of Winter")
	then
		ccrCast("Horn of Winter")
		return
	end

	if ccrPlayerRunicPower() <= ccRS.DeathKnight_HornOfWinterLimit
	and ccrPlayerIsInCombat()
	and SpellIsReady("Horn of Winter")
	then
		ccrCast("Horn of Winter")
		return
	end
end

function ccR_DeathKnight_Icebound_Fortitude()
	local vUseIceboundFortitude = ccRS.DeathKnight_UseIceboundFortitude
	local vHealth = ccRS.DeathKnight_IceboundFortitudeHP

	if ccrPlayerHasSpell(ICEBOUND_FORTITUDE)
	and vUseIceboundFortitude
	and ccrSpellIsReady(ICEBOUND_FORTITUDE)
	and ccrPlayerHealth() <= vHeallth
	then
		ccrCast(ICEBOUND_FORTITUDE)
		return
	end
	return
end

function ccR_DeathKnight_Raise_Ally()
	if (PlayerIsInDungeon() or PlayerIsInRaid())
	and SpellIsReady("Raise Ally")
	then
		local vPlayer
		local vGroupType
		local objPlayer
		if GetNumGroupMembers() == 0 then return end;
		if GetNumGroupMembers() <= 5 then vGroupType = "party" elseif GetNumGroupMembers() >= 6 then vGroupType = "raid" end
		for i = 0, GetNumGroupMembers() do
			vPlayer = vGroupType .. tostring(i)
			objPlayer = GetObjectFromUnitID(vPlayer)
			if UnitIsDead(vPlayer) == 1
			and IsSpellInRange("Raise Ally", vPlayer) == 1
			and objPlayer:InLineOfSight()
			then
				ccrCast("Raise Ally", vPlayer)
			end
		end
	end
end